/**
 * @file common_macro.h
 * @brief This file defined alot of macros.
 * @author marco
 * @version v1.0
 * @date 2012-08-24
 */
#ifndef __COMMON_MACRO_H_
#define __COMMON_MACRO_H_

#define CLEAR(x) memset(&(x), 0, sizeof(x))
#define SIZEOF_ARRAY(x)	(sizeof(x)/sizeof(x[0]))
#define STRLEN(s)	(((s) == NULL) ? 0 : strlen(s))
#define FREE(p)	{if(p) {free((void *)p); p = NULL;}}

#define	TO_LOWER(x)			(((x)>='A' && (x)<='Z')?((x)+('a'-'A')):(x))
#define IS_LOWER_ALPHA(x)	(((x)>='a' && (x)<='z')?(1):(0))
#define IS_DIGIT(x)			(((x)>='0' && (x)<='9')?(1):(0))
#define IS_SYMBOL(x)		((IS_LOWER_ALPHA(x)||IS_DIGIT(x))?(0):(1))

#endif
